<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .progress-bar {
  width: 100%;
  height: 30px;
  background-color: #ddd;
  border-radius: 5px;
}
 
.progress {
  width: 0%;
  height: 100%;
  background-color: #4CAF50;
  border-radius: 5px;
  transition: width 5s linear;
}
 
.percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
 
  </style>
</head>
<body>
  <div class="progress-bar">
    <div class="progress"></div>
    <div class="percent">0%</div>
  </div>
  
 
  <script>
    // 获取HTML元素
const progress = document.querySelector('.progress');
const percent = document.querySelector('.percent');
 
// 定义初始进度
let currentProgress = 0;
 
// 定义更新进度函数
function updateProgress() {
  if (currentProgress <= 100) {
    progress.style.width = `${currentProgress}%`;
    percent.textContent = `${currentProgress}%`;
    currentProgress++;
    setTimeout(updateProgress,1000);
  }
}
 
// 调用更新进度函数
updateProgress();
 
  </script>
</body>
</html>